<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>文档</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <style>
        .empty{ text-align: center; padding: 120px 0; }
        .list_content_padded {padding: 10px 10px 0}
        .account_item {
    border: 1px solid #ccc;
    background: #fff;
    padding: 15px;
    margin-bottom: 10px;
    color: #8B8A8A;
    overflow: hidden;
}
        .total_income_title {
    margin: 15px 0 0 15px;
}
       .total_income_content {
    text-align: center;
    margin: 30px 0;
} 
        .total_income_content span {
    font-size: 42px;
    color: #2DD282;
}
.list_money {
    border-top: 1px solid #ccc;
    padding: 10px 15px 20px;
    line-height: 36px;
}
.td_receivables {
    text-align: right;
}
.list_button {
    width: 100%;
    height: 50px;
    border: 0;
    border-radius: 5px;
    background: #ec6d65;
    color: #fff;
    font-size: 18px;
}
.logout_btn {
    border: 1px solid #ccc;
    background: #fff;
    padding: 15px;
    margin-top: 10px;
    color: #8B8A8A;
    overflow: hidden;
}
.account_item .list_button {
    height: 40px;
    width: 40%;
    float: right;
}
.account_item .apply_drewings {
    background: #ec6d65;
    color: #fff;
}
body{background:#EFEFF4;}  
    </style>
</head>
<body>
    <div class="list_content_padded">
		<div class="account_item">
			<div class="total_income_title">总收入：</div>
			<div class="total_income_content"><span id="total_income_content"></span>元</div>
			<div class="list_money">
				<div class="td_collection">总收入包括已提款金额和未提款金额之和。</div>
			</div>
			
		</div>
		<div class="logout_btn" id="logout_btn" onclick="inquireLogout();">
			<div class="">安全退出</div>
		</div>
	</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/urlpath.js"></script>
<script>
	apiready = function () {
        setRefreshHeader();
        rendorAccount();
    } 
    $api.addEvt($api.byId("logout_btn"), 'touchstart', function(e) {
        $api.css($api.byId("logout_btn"),'background:#eee;');
    });
    $api.addEvt($api.byId("logout_btn"), 'touchend', function(e) {
        $api.css($api.byId("logout_btn"),'background:#fff;');
    });
    function setRefreshHeader() { //下拉刷新
        api.setRefreshHeaderInfo({
            visible: true,
            bgColor: '#ccc',
            textColor: '#fff',
            textDown: '下拉刷新...',
            textUp: '松开刷新...',
            showTime: true
        }, function (ret, err) {
            rendorAccount();
            api.refreshHeaderLoadDone();
        });
    }

    var total_revenue = 0;
    function rendorAccount(){
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '努力加载中...',
            text: '请稍候...',
            modal: false
        });
        api.ajax({
            url: URLpath+'/ajax/call/vender_admin/balance_info',
            method: 'post',
            timeout:5
        },function(ret, err){
            api.hideProgress();
            if (ret) {
                if(!ret || ret.errno ){
                    // alert(ret.errmsg);
                    api.toast({
                        msg: ret.errmsg,
                        duration: 2000,
                        location: 'middle'
                    });
                }else{
                    var res = ret ;
                    total_revenue = res.total_revenue;
                    $api.text($api.byId("total_income_content"),res.total_revenue);
                }
            } else {
                api.confirm({
                    title: '系统提示',
                    msg: '网络请求超时，下拉刷新试试？',
                    buttons: ['确定']
                },function( ret, err ){
                    
                });
            }
        });
    }
    function inquireLogout(){
        api.confirm({
            title: '系统提示',
            msg: '确定要安全退出吗？',
            buttons: ['取消', '确定']
        },function( ret, err ){
            if( ret ){
                 if(ret.buttonIndex == "1"){
                    
                 }else{
                    logoutFun();
                 }
            }else{
                 // alert( JSON.stringify( ret ) );
            }
        });
    }
    function logoutFun(){
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '努力加载中...',
            text: '请稍候...',
            modal: false
        });
        api.ajax({
            url: URLpath+'/logout/index?format=json',
            method: 'post'
        },function(ret, err){
            api.hideProgress();
            
            if (ret.redirect_to == "/login") {
                // $api.clearStorage();
                $api.rmStorage("login_name"); 
                $api.rmStorage("pwd"); 
                setTimeout(function(){
                    // openWinLogin();
                    // api.closeWidget({
                    //     silent : false
                    // });
                    api.closeToWin({
                        name: 'login'    //B画面的window名称
                    });
                },500);
            }else{
                // alert(ret.errmsg);
                api.toast({
                    msg: ret.errmsg,
                    duration: 2000,
                    location: 'middle'
                });
            }
        });
    }
    function openWinLogin(){
        api.openWin({
            name: 'login',
            slidBackEnabled:false,
            animation:{
                type:"movein",                
                subType:"from_left",       
                duration:300,               
                curve:"ease_out"
            },
            url: URLpath+'/respagenew/call/venderappnew/login.html',
            pageParam:{
                'winReload':'winReload'
            }
        });
    }
</script>
</html>